<?php

namespace app\admin\controller;

use Qiniu\Auth;

class File extends FileBase
{
    public function getQiniuToken()
    {
        // 用于签名的公钥和私钥
        $accessKey = env('QINIU_ACCESS_KEY');
        $secretKey = env('QINIU_SECRET_KEY');

        // 初始化签权对象
        $auth = new Auth($accessKey, $secretKey);

        // 生成上传Token
        $token = $auth->uploadToken(env('QINIU_NAMESPACE'));

        return json(['code' => 20000,  'data' => $token]);
    }
}
